From c21ebdf787bdd58c87cc4ce933db4c0e8318e529 Mon Sep 17 00:00:00 2001 From: joanestebanr <129153821+joanestebanr@users.noreply.github.com> Date: Thu, 28 Nov 2024 12:52:45 +0100 Subject: [PATCH 01/10] feat: store retries and discarded certificates on storage (configurable) --- aggsender/aggsender.go | 9 +++- aggsender/aggsender_test.go | 6 ++- aggsender/config.go | 2 + aggsender/db/aggsender_db_storage.go | 55 ++++++++++++++++------- aggsender/db/aggsender_db_storage_test.go | 26 ++++++++--- aggsender/db/migrations/0001.sql | 25 +++++++++-- aggsender/db/migrations/migrations.go | 6 ++- aggsender/types/types.go | 4 +- config/default.go | 1 + db/migrations.go | 11 +++-- 10 files changed, 111 insertions(+), 34 deletions(-) diff --git a/aggsender/aggsender.go b/aggsender/aggsender.go index 42e518fd2..77b385ff6 100644 --- a/aggsender/aggsender.go +++ b/aggsender/aggsender.go @@ -55,7 +55,11 @@ func New( l1InfoTreeSyncer *l1infotreesync.L1InfoTreeSync, l2Syncer types.L2BridgeSyncer, epochNotifier types.EpochNotifier) (*AggSender, error) { - storage, err := db.NewAggSenderSQLStorage(logger, cfg.StoragePath) + storageConfig := db.AggSenderSQLStorageConfig{ + DBPath: cfg.StoragePath, + KeepCertificatesHistory: cfg.KeepCertificatesHistory, + } + storage, err := db.NewAggSenderSQLStorage(logger, storageConfig) if err != nil { return nil, err } @@ -153,12 +157,14 @@ func (a *AggSender) sendCertificate(ctx context.Context) (*agglayer.SignedCertif return nil, err } previousToBlock := uint64(0) + retryCount := 0 if lastSentCertificateInfo != nil { previousToBlock = lastSentCertificateInfo.ToBlock if lastSentCertificateInfo.Status == agglayer.InError { // if the last certificate was in error, we need to resend it // from the block before the error previousToBlock = lastSentCertificateInfo.FromBlock - 1 + retryCount = lastSentCertificateInfo.RetryCount + 1 } } @@ -216,6 +222,7 @@ func (a *AggSender) sendCertificate(ctx context.Context) (*agglayer.SignedCertif prevLER := common.BytesToHash(certificate.PrevLocalExitRoot[:]) certInfo := types.CertificateInfo{ Height: certificate.Height, + RetryCount: retryCount, CertificateID: certificateHash, NewLocalExitRoot: certificate.NewLocalExitRoot, PreviousLocalExitRoot: &prevLER, diff --git a/aggsender/aggsender_test.go b/aggsender/aggsender_test.go index 79504f6a0..279e64337 100644 --- a/aggsender/aggsender_test.go +++ b/aggsender/aggsender_test.go @@ -1951,7 +1951,11 @@ func newAggsenderTestData(t *testing.T, creationFlags testDataFlags) *aggsenderT pc, _, _, _ := runtime.Caller(1) part := runtime.FuncForPC(pc) dbPath := fmt.Sprintf("file:%d?mode=memory&cache=shared", part.Entry()) - storage, err = db.NewAggSenderSQLStorage(logger, dbPath) + storageConfig := db.AggSenderSQLStorageConfig{ + DBPath: dbPath, + KeepCertificatesHistory: true, + } + storage, err = db.NewAggSenderSQLStorage(logger, storageConfig) require.NoError(t, err) } diff --git a/aggsender/config.go b/aggsender/config.go index b36fbe7a2..cfd0b63c5 100644 --- a/aggsender/config.go +++ b/aggsender/config.go @@ -36,6 +36,8 @@ type Config struct { // DelayBeetweenRetries is the delay between retries: // is used on store Certificate and also in initial check DelayBeetweenRetries types.Duration `mapstructure:"DelayBeetweenRetries"` + // KeepCertificatesHistory is a flag to keep the certificates history on storage + KeepCertificatesHistory bool `mapstructure:"KeepCertificatesHistory"` } // String returns a string representation of the Config diff --git a/aggsender/db/aggsender_db_storage.go b/aggsender/db/aggsender_db_storage.go index 00440f4ac..e036b94d9 100644 --- a/aggsender/db/aggsender_db_storage.go +++ b/aggsender/db/aggsender_db_storage.go @@ -36,26 +36,33 @@ type AggSenderStorage interface { var _ AggSenderStorage = (*AggSenderSQLStorage)(nil) +// AggSenderSQLStorageConfig is the configuration for the AggSenderSQLStorage +type AggSenderSQLStorageConfig struct { + DBPath string + KeepCertificatesHistory bool +} + // AggSenderSQLStorage is the struct that implements the AggSenderStorage interface type AggSenderSQLStorage struct { logger *log.Logger db *sql.DB + cfg AggSenderSQLStorageConfig } // NewAggSenderSQLStorage creates a new AggSenderSQLStorage -func NewAggSenderSQLStorage(logger *log.Logger, dbPath string) (*AggSenderSQLStorage, error) { - if err := migrations.RunMigrations(dbPath); err != nil { +func NewAggSenderSQLStorage(logger *log.Logger, cfg AggSenderSQLStorageConfig) (*AggSenderSQLStorage, error) { + db, err := db.NewSQLiteDB(cfg.DBPath) + if err != nil { return nil, err } - - db, err := db.NewSQLiteDB(dbPath) - if err != nil { + if err := migrations.RunMigrations(logger, db); err != nil { return nil, err } return &AggSenderSQLStorage{ db: db, logger: logger, + cfg: cfg, }, nil } @@ -93,7 +100,7 @@ func (a *AggSenderSQLStorage) GetCertificateByHeight(height uint64) (*types.Cert } // getCertificateByHeight returns a certificate by its height using the provided db -func getCertificateByHeight(db meddler.DB, +func getCertificateByHeight(db db.Querier, height uint64) (*types.CertificateInfo, error) { var certificateInfo types.CertificateInfo if err := meddler.QueryRow(db, &certificateInfo, @@ -119,7 +126,7 @@ func (a *AggSenderSQLStorage) GetLastSentCertificate() (*types.CertificateInfo, func (a *AggSenderSQLStorage) SaveLastSentCertificate(ctx context.Context, certificate types.CertificateInfo) error { tx, err := db.NewTx(ctx, a.db) if err != nil { - return err + return fmt.Errorf("saveLastSentCertificate NewTx. Err: %w", err) } defer func() { if err != nil { @@ -131,14 +138,14 @@ func (a *AggSenderSQLStorage) SaveLastSentCertificate(ctx context.Context, certi cert, err := getCertificateByHeight(tx, certificate.Height) if err != nil && !errors.Is(err, db.ErrNotFound) { - return err + return fmt.Errorf("saveLastSentCertificate getCertificateByHeight. Err: %w", err) } if cert != nil { // we already have a certificate with this height // we need to delete it before inserting the new one - if err = deleteCertificate(tx, cert.CertificateID); err != nil { - return err + if err = a.moveCertificateToHistory(tx, cert); err != nil { + return fmt.Errorf("saveLastSentCertificate moveCertificateToHistory Err: %w", err) } } @@ -147,7 +154,7 @@ func (a *AggSenderSQLStorage) SaveLastSentCertificate(ctx context.Context, certi } if err = tx.Commit(); err != nil { - return err + return fmt.Errorf("saveLastSentCertificate commit. Err: %w", err) } a.logger.Debugf("inserted certificate - Height: %d. Hash: %s", certificate.Height, certificate.CertificateID) @@ -155,6 +162,22 @@ func (a *AggSenderSQLStorage) SaveLastSentCertificate(ctx context.Context, certi return nil } +func (a *AggSenderSQLStorage) moveCertificateToHistory(tx db.Querier, certificate *types.CertificateInfo) error { + if a.cfg.KeepCertificatesHistory { + a.logger.Debugf("moving certificate to history - new CertificateID: %s", certificate.ID()) + if _, err := tx.Exec(`INSERT INTO certificate_info_history SELECT * FROM certificate_info WHERE height = $1;`, + certificate.Height); err != nil { + return fmt.Errorf("error moving certificate to history: %w", err) + } + } + a.logger.Debugf("deleting certificate - CertificateID: %s", certificate.ID()) + if err := deleteCertificate(tx, certificate.CertificateID); err != nil { + return fmt.Errorf("deleteCertificate %s . Error: %w", certificate.ID(), err) + } + + return nil +} + // DeleteCertificate deletes a certificate from the storage func (a *AggSenderSQLStorage) DeleteCertificate(ctx context.Context, certificateID common.Hash) error { tx, err := db.NewTx(ctx, a.db) @@ -169,7 +192,7 @@ func (a *AggSenderSQLStorage) DeleteCertificate(ctx context.Context, certificate } }() - if err = deleteCertificate(a.db, certificateID); err != nil { + if err = deleteCertificate(tx, certificateID); err != nil { return err } @@ -183,8 +206,8 @@ func (a *AggSenderSQLStorage) DeleteCertificate(ctx context.Context, certificate } // deleteCertificate deletes a certificate from the storage using the provided db -func deleteCertificate(db meddler.DB, certificateID common.Hash) error { - if _, err := db.Exec(`DELETE FROM certificate_info WHERE certificate_id = $1;`, certificateID.String()); err != nil { +func deleteCertificate(tx db.Querier, certificateID common.Hash) error { + if _, err := tx.Exec(`DELETE FROM certificate_info WHERE certificate_id = $1;`, certificateID.String()); err != nil { return fmt.Errorf("error deleting certificate info: %w", err) } @@ -205,8 +228,8 @@ func (a *AggSenderSQLStorage) UpdateCertificate(ctx context.Context, certificate } }() - if _, err = tx.Exec(`UPDATE certificate_info SET status = $1 WHERE certificate_id = $2;`, - certificate.Status, certificate.CertificateID.String()); err != nil { + if _, err = tx.Exec(`UPDATE certificate_info SET status = $1, updated_at=$2 WHERE certificate_id = $3;`, + certificate.Status, certificate.UpdatedAt, certificate.CertificateID.String()); err != nil { return fmt.Errorf("error updating certificate info: %w", err) } if err = tx.Commit(); err != nil { diff --git a/aggsender/db/aggsender_db_storage_test.go b/aggsender/db/aggsender_db_storage_test.go index 15c017bc0..1af0df868 100644 --- a/aggsender/db/aggsender_db_storage_test.go +++ b/aggsender/db/aggsender_db_storage_test.go @@ -9,7 +9,6 @@ import ( "time" "github.com/0xPolygon/cdk/agglayer" - "github.com/0xPolygon/cdk/aggsender/db/migrations" "github.com/0xPolygon/cdk/aggsender/types" "github.com/0xPolygon/cdk/db" "github.com/0xPolygon/cdk/log" @@ -22,9 +21,12 @@ func Test_Storage(t *testing.T) { path := path.Join(t.TempDir(), "file::memory:?cache=shared") log.Debugf("sqlite path: %s", path) - require.NoError(t, migrations.RunMigrations(path)) + cfg := AggSenderSQLStorageConfig{ + DBPath: path, + KeepCertificatesHistory: true, + } - storage, err := NewAggSenderSQLStorage(log.WithFields("aggsender-db"), path) + storage, err := NewAggSenderSQLStorage(log.WithFields("aggsender-db"), cfg) require.NoError(t, err) updateTime := time.Now().UTC().UnixMilli() @@ -201,6 +203,7 @@ func Test_Storage(t *testing.T) { // Insert a certificate certificate := types.CertificateInfo{ Height: 13, + RetryCount: 1234, CertificateID: common.HexToHash("0xD"), NewLocalExitRoot: common.HexToHash("0xE"), FromBlock: 13, @@ -213,12 +216,14 @@ func Test_Storage(t *testing.T) { // Update the status of the certificate certificate.Status = agglayer.Settled + certificate.UpdatedAt = updateTime + 1 require.NoError(t, storage.UpdateCertificate(ctx, certificate)) // Fetch the certificate and verify the status has been updated certificateFromDB, err := storage.GetCertificateByHeight(certificate.Height) require.NoError(t, err) - require.Equal(t, certificate.Status, certificateFromDB.Status) + require.Equal(t, certificate.Status, certificateFromDB.Status, "equal status") + require.Equal(t, certificate.UpdatedAt, certificateFromDB.UpdatedAt, "equal updated at") require.NoError(t, storage.clean()) }) @@ -229,9 +234,12 @@ func Test_SaveLastSentCertificate(t *testing.T) { path := path.Join(t.TempDir(), "file::memory:?cache=shared") log.Debugf("sqlite path: %s", path) - require.NoError(t, migrations.RunMigrations(path)) + cfg := AggSenderSQLStorageConfig{ + DBPath: path, + KeepCertificatesHistory: true, + } - storage, err := NewAggSenderSQLStorage(log.WithFields("aggsender-db"), path) + storage, err := NewAggSenderSQLStorage(log.WithFields("aggsender-db"), cfg) require.NoError(t, err) updateTime := time.Now().UTC().UnixMilli() @@ -372,7 +380,11 @@ func Test_SaveLastSentCertificate(t *testing.T) { func Test_StoragePreviousLER(t *testing.T) { ctx := context.TODO() dbPath := path.Join(t.TempDir(), "Test_StoragePreviousLER.sqlite") - storage, err := NewAggSenderSQLStorage(log.WithFields("aggsender-db"), dbPath) + cfg := AggSenderSQLStorageConfig{ + DBPath: dbPath, + KeepCertificatesHistory: true, + } + storage, err := NewAggSenderSQLStorage(log.WithFields("aggsender-db"), cfg) require.NoError(t, err) require.NotNil(t, storage) diff --git a/aggsender/db/migrations/0001.sql b/aggsender/db/migrations/0001.sql index ebc68c515..d418f1d89 100644 --- a/aggsender/db/migrations/0001.sql +++ b/aggsender/db/migrations/0001.sql @@ -1,10 +1,13 @@ -- +migrate Down DROP TABLE IF EXISTS certificate_info; +DROP TABLE IF EXISTS certificate_info_history; +DROP TABLE IF EXISTS certificate_info_history; -- +migrate Up CREATE TABLE certificate_info ( height INTEGER NOT NULL, - certificate_id VARCHAR NOT NULL PRIMARY KEY, + retry_count INTEGER DEFAULT 0, + certificate_id VARCHAR NOT NULL, status INTEGER NOT NULL, previous_local_exit_root VARCHAR, new_local_exit_root VARCHAR NOT NULL, @@ -12,5 +15,21 @@ CREATE TABLE certificate_info ( to_block INTEGER NOT NULL, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, - signed_certificate TEXT -); \ No newline at end of file + signed_certificate TEXT, + PRIMARY KEY (height) +); + +CREATE TABLE certificate_info_history ( + height INTEGER NOT NULL , + retry_count INTEGER DEFAULT 0, + certificate_id VARCHAR NOT NULL, + status INTEGER NOT NULL, + previous_local_exit_root VARCHAR, + new_local_exit_root VARCHAR NOT NULL, + from_block INTEGER NOT NULL, + to_block INTEGER NOT NULL, + created_at INTEGER NOT NULL, + updated_at INTEGER NOT NULL, + signed_certificate TEXT, + PRIMARY KEY (height, retry_count) +); diff --git a/aggsender/db/migrations/migrations.go b/aggsender/db/migrations/migrations.go index 31f16fd24..78c58b85e 100644 --- a/aggsender/db/migrations/migrations.go +++ b/aggsender/db/migrations/migrations.go @@ -1,16 +1,18 @@ package migrations import ( + "database/sql" _ "embed" "github.com/0xPolygon/cdk/db" "github.com/0xPolygon/cdk/db/types" + "github.com/0xPolygon/cdk/log" ) //go:embed 0001.sql var mig001 string -func RunMigrations(dbPath string) error { +func RunMigrations(logger *log.Logger, database *sql.DB) error { migrations := []types.Migration{ { ID: "0001", @@ -18,5 +20,5 @@ func RunMigrations(dbPath string) error { }, } - return db.RunMigrations(dbPath, migrations) + return db.RunMigrationsDB(logger, database, migrations) } diff --git a/aggsender/types/types.go b/aggsender/types/types.go index 1c0d8353e..090b57b7b 100644 --- a/aggsender/types/types.go +++ b/aggsender/types/types.go @@ -56,6 +56,7 @@ type Logger interface { type CertificateInfo struct { Height uint64 `meddler:"height"` + RetryCount int `meddler:"retry_count"` CertificateID common.Hash `meddler:"certificate_id,hash"` // PreviousLocalExitRoot if it's nil means no reported PreviousLocalExitRoot *common.Hash `meddler:"previous_local_exit_root,hash"` @@ -88,6 +89,7 @@ func (c *CertificateInfo) String() string { "CreatedAt: %s "+ "UpdatedAt: %s", c.Height, + c.RetryCount, c.CertificateID.String(), previousLocalExitRoot, c.NewLocalExitRoot.String(), @@ -104,7 +106,7 @@ func (c *CertificateInfo) ID() string { if c == nil { return "nil" } - return fmt.Sprintf("%d/%s", c.Height, c.CertificateID.String()) + return fmt.Sprintf("%d/%s (retry %d)", c.Height, c.CertificateID.String(), c.RetryCount) } // IsClosed returns true if the certificate is closed (settled or inError) diff --git a/config/default.go b/config/default.go index b1cfe16ee..6a505b88e 100644 --- a/config/default.go +++ b/config/default.go @@ -339,4 +339,5 @@ EpochNotificationPercentage = 50 SaveCertificatesToFilesPath = "" MaxRetriesStoreCertificate = 3 DelayBeetweenRetries = "60s" +KeepCertificatesHistory = true ` diff --git a/db/migrations.go b/db/migrations.go index 1a56874ec..8af35874e 100644 --- a/db/migrations.go +++ b/db/migrations.go @@ -1,6 +1,7 @@ package db import ( + "database/sql" "fmt" "strings" @@ -23,6 +24,10 @@ func RunMigrations(dbPath string, migrations []types.Migration) error { if err != nil { return fmt.Errorf("error creating DB %w", err) } + return RunMigrationsDB(log.GetDefaultLogger(), db, migrations) +} + +func RunMigrationsDB(logger *log.Logger, db *sql.DB, migrations []types.Migration) error { migs := &migrate.MemoryMigrationSource{Migrations: []*migrate.Migration{}} for _, m := range migrations { prefixed := strings.ReplaceAll(m.SQL, dbPrefixReplacer, m.Prefix) @@ -34,15 +39,15 @@ func RunMigrations(dbPath string, migrations []types.Migration) error { }) } - log.Debugf("running migrations:") + logger.Debugf("running migrations:") for _, m := range migs.Migrations { - log.Debugf("%+v", m.Id) + logger.Debugf("%+v", m.Id) } nMigrations, err := migrate.Exec(db, "sqlite3", migs, migrate.Up) if err != nil { return fmt.Errorf("error executing migration %w", err) } - log.Infof("successfully ran %d migrations", nMigrations) + logger.Infof("successfully ran %d migrations", nMigrations) return nil } From be1f73a2906ef8e8297325f5cd46b0200326199e Mon Sep 17 00:00:00 2001 From: joanestebanr <129153821+joanestebanr@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:26:25 +0100 Subject: [PATCH 02/10] fix: ut --- aggsender/types/types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/aggsender/types/types.go b/aggsender/types/types.go index 090b57b7b..432ca9531 100644 --- a/aggsender/types/types.go +++ b/aggsender/types/types.go @@ -80,6 +80,7 @@ func (c *CertificateInfo) String() string { } return fmt.Sprintf("aggsender.CertificateInfo: "+ "Height: %d "+ + "RetryCount: %d "+ "CertificateID: %s "+ "PreviousLocalExitRoot: %s "+ "NewLocalExitRoot: %s "+ From 200331bcdfa4192664b428bd112f93b4120051ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:43:32 +0100 Subject: [PATCH 03/10] chore: bump kurtosis-cdk version to support pre-deployed gas token (#202) * chore: kurtosis-cdk bump (gas token update) * test * chore: use new kurtosis-cdk tag * chore: nit * chore: clean up --- .github/workflows/test-e2e.yml | 41 ++++++----------------- .github/workflows/test-resequence.yml | 13 ++----- test/combinations/fork11-rollup.yml | 3 +- test/combinations/fork12-cdk-validium.yml | 4 +-- test/combinations/fork12-pessimistic.yml | 2 +- test/combinations/fork12-rollup.yml | 2 +- test/combinations/fork9-cdk-validium.yml | 2 +- 7 files changed, 18 insertions(+), 49 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 9f0244985..9451612aa 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -33,26 +33,17 @@ jobs: - name: Build Docker run: make build-docker - - # this is better to get the action in - - name: Install kurtosis - shell: bash - run: | - echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list - sudo apt update - sudo apt install kurtosis-cli=1.4.1 - kurtosis version - - - name: Disable kurtosis analytics - shell: bash - run: kurtosis analytics disable - - - name: Install yq - shell: bash - run: | - pip3 install yq - yq --version - + + - name: Checkout kurtosis-cdk + uses: actions/checkout@v4 + with: + repository: 0xPolygon/kurtosis-cdk + path: kurtosis-cdk + ref: v0.2.22 + + - name: Install Kurtosis CDK tools + uses: ./kurtosis-cdk/.github/actions/setup-kurtosis-cdk + - name: Install polycli run: | POLYCLI_VERSION="${{ vars.POLYCLI_VERSION }}" @@ -63,16 +54,6 @@ jobs: sudo chmod +x /usr/local/bin/polycli /usr/local/bin/polycli version - - name: Install foundry - uses: foundry-rs/foundry-toolchain@v1 - - - name: checkout kurtosis-cdk - uses: actions/checkout@v4 - with: - repository: 0xPolygon/kurtosis-cdk - path: "kurtosis-cdk" - ref: "v0.2.21" - - name: Setup Bats and bats libs uses: bats-core/bats-action@2.0.0 diff --git a/.github/workflows/test-resequence.yml b/.github/workflows/test-resequence.yml index 66bc437ac..d280c5f16 100644 --- a/.github/workflows/test-resequence.yml +++ b/.github/workflows/test-resequence.yml @@ -23,7 +23,7 @@ jobs: with: path: cdk - - name: Checkout kurtosis-cdk + - name: Checkout cdk-erigon uses: actions/checkout@v4 with: repository: 0xPolygonHermez/cdk-erigon @@ -34,21 +34,12 @@ jobs: uses: actions/checkout@v4 with: repository: 0xPolygon/kurtosis-cdk - ref: a7a80b7b5d98a69a23415ab0018e556257a6dfb6 path: kurtosis-cdk + ref: v0.2.22 - name: Install Kurtosis CDK tools uses: ./kurtosis-cdk/.github/actions/setup-kurtosis-cdk - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - - - name: Install yq - run: | - sudo curl -L https://github.com/mikefarah/yq/releases/download/v4.44.2/yq_linux_amd64 -o /usr/local/bin/yq - sudo chmod +x /usr/local/bin/yq - /usr/local/bin/yq --version - - name: Install polycli run: | POLYCLI_VERSION="${{ vars.POLYCLI_VERSION }}" diff --git a/test/combinations/fork11-rollup.yml b/test/combinations/fork11-rollup.yml index 79baa92d2..a0ffba40f 100644 --- a/test/combinations/fork11-rollup.yml +++ b/test/combinations/fork11-rollup.yml @@ -4,7 +4,6 @@ args: cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.1.2 zkevm_node_image: hermeznetwork/zkevm-node:v0.7.0-fork11-RC1 cdk_node_image: cdk - zkevm_use_gas_token_contract: true + gas_token_enabled: true data_availability_mode: rollup sequencer_type: erigon - \ No newline at end of file diff --git a/test/combinations/fork12-cdk-validium.yml b/test/combinations/fork12-cdk-validium.yml index c17444b30..0836fb083 100644 --- a/test/combinations/fork12-cdk-validium.yml +++ b/test/combinations/fork12-cdk-validium.yml @@ -3,8 +3,6 @@ args: zkevm_prover_image: hermeznetwork/zkevm-prover:v8.0.0-RC12-fork.12 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.1.2 cdk_node_image: cdk - zkevm_use_gas_token_contract: true + gas_token_enabled: true data_availability_mode: cdk-validium sequencer_type: erigon - - diff --git a/test/combinations/fork12-pessimistic.yml b/test/combinations/fork12-pessimistic.yml index d92375c51..ebac2c514 100644 --- a/test/combinations/fork12-pessimistic.yml +++ b/test/combinations/fork12-pessimistic.yml @@ -10,6 +10,6 @@ args: consensus_contract_type: pessimistic sequencer_type: erigon erigon_strict_mode: false - zkevm_use_gas_token_contract: true + gas_token_enabled: true agglayer_prover_sp1_key: {{.agglayer_prover_sp1_key}} enable_normalcy: true diff --git a/test/combinations/fork12-rollup.yml b/test/combinations/fork12-rollup.yml index 95a5111a8..ca597faa3 100644 --- a/test/combinations/fork12-rollup.yml +++ b/test/combinations/fork12-rollup.yml @@ -3,6 +3,6 @@ args: zkevm_prover_image: hermeznetwork/zkevm-prover:v8.0.0-RC12-fork.12 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.1.2 cdk_node_image: cdk - zkevm_use_gas_token_contract: true + gas_token_enabled: true data_availability_mode: rollup sequencer_type: erigon diff --git a/test/combinations/fork9-cdk-validium.yml b/test/combinations/fork9-cdk-validium.yml index e05436546..67b23bd09 100644 --- a/test/combinations/fork9-cdk-validium.yml +++ b/test/combinations/fork9-cdk-validium.yml @@ -5,7 +5,7 @@ args: zkevm_node_image: hermeznetwork/zkevm-node:v0.7.3-RC1 cdk_validium_node_image: 0xpolygon/cdk-validium-node:0.7.0-cdk cdk_node_image: cdk - zkevm_use_gas_token_contract: true + gas_token_enabled: true additional_services: - pless_zkevm_node data_availability_mode: cdk-validium From 067fcb45e52c2f858ad3dc8753668a1029dd9b0f Mon Sep 17 00:00:00 2001 From: Joan Esteban <129153821+joanestebanr@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:57:03 +0100 Subject: [PATCH 04/10] feat: PR comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Toni Ramírez <58293609+ToniRamirezM@users.noreply.github.com> --- aggsender/db/aggsender_db_storage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aggsender/db/aggsender_db_storage.go b/aggsender/db/aggsender_db_storage.go index e036b94d9..3e02662fc 100644 --- a/aggsender/db/aggsender_db_storage.go +++ b/aggsender/db/aggsender_db_storage.go @@ -228,7 +228,7 @@ func (a *AggSenderSQLStorage) UpdateCertificate(ctx context.Context, certificate } }() - if _, err = tx.Exec(`UPDATE certificate_info SET status = $1, updated_at=$2 WHERE certificate_id = $3;`, + if _, err = tx.Exec(`UPDATE certificate_info SET status = $1, updated_at = $2 WHERE certificate_id = $3;`, certificate.Status, certificate.UpdatedAt, certificate.CertificateID.String()); err != nil { return fmt.Errorf("error updating certificate info: %w", err) } From be267115b9a135e6553ccb96e19752d946780327 Mon Sep 17 00:00:00 2001 From: joanestebanr <129153821+joanestebanr@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:51:35 +0100 Subject: [PATCH 05/10] fix: PR comments --- aggsender/db/aggsender_db_storage.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aggsender/db/aggsender_db_storage.go b/aggsender/db/aggsender_db_storage.go index 3e02662fc..b8225dca1 100644 --- a/aggsender/db/aggsender_db_storage.go +++ b/aggsender/db/aggsender_db_storage.go @@ -144,7 +144,7 @@ func (a *AggSenderSQLStorage) SaveLastSentCertificate(ctx context.Context, certi if cert != nil { // we already have a certificate with this height // we need to delete it before inserting the new one - if err = a.moveCertificateToHistory(tx, cert); err != nil { + if err = a.moveCertificateToHistoryOrDelete(tx, cert); err != nil { return fmt.Errorf("saveLastSentCertificate moveCertificateToHistory Err: %w", err) } } @@ -162,7 +162,7 @@ func (a *AggSenderSQLStorage) SaveLastSentCertificate(ctx context.Context, certi return nil } -func (a *AggSenderSQLStorage) moveCertificateToHistory(tx db.Querier, certificate *types.CertificateInfo) error { +func (a *AggSenderSQLStorage) moveCertificateToHistoryOrDelete(tx db.Querier, certificate *types.CertificateInfo) error { if a.cfg.KeepCertificatesHistory { a.logger.Debugf("moving certificate to history - new CertificateID: %s", certificate.ID()) if _, err := tx.Exec(`INSERT INTO certificate_info_history SELECT * FROM certificate_info WHERE height = $1;`, From 2003c3a806ea4041f0359bad3daf44bc5b426a3c Mon Sep 17 00:00:00 2001 From: joanestebanr <129153821+joanestebanr@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:25:28 +0100 Subject: [PATCH 06/10] fix: lint --- aggsender/db/aggsender_db_storage.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aggsender/db/aggsender_db_storage.go b/aggsender/db/aggsender_db_storage.go index b8225dca1..597a9bd06 100644 --- a/aggsender/db/aggsender_db_storage.go +++ b/aggsender/db/aggsender_db_storage.go @@ -162,7 +162,8 @@ func (a *AggSenderSQLStorage) SaveLastSentCertificate(ctx context.Context, certi return nil } -func (a *AggSenderSQLStorage) moveCertificateToHistoryOrDelete(tx db.Querier, certificate *types.CertificateInfo) error { +func (a *AggSenderSQLStorage) moveCertificateToHistoryOrDelete(tx db.Querier, + certificate *types.CertificateInfo) error { if a.cfg.KeepCertificatesHistory { a.logger.Debugf("moving certificate to history - new CertificateID: %s", certificate.ID()) if _, err := tx.Exec(`INSERT INTO certificate_info_history SELECT * FROM certificate_info WHERE height = $1;`, From d73384563e91d09b6537010584b0c1bf0be8862a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Mon, 2 Dec 2024 14:51:18 +0100 Subject: [PATCH 07/10] fix: bump the kurtosis cdk version and pass the CI --- .github/workflows/test-e2e.yml | 2 +- .github/workflows/test-resequence.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 9451612aa..a44b129a1 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -39,7 +39,7 @@ jobs: with: repository: 0xPolygon/kurtosis-cdk path: kurtosis-cdk - ref: v0.2.22 + ref: v0.2.23 - name: Install Kurtosis CDK tools uses: ./kurtosis-cdk/.github/actions/setup-kurtosis-cdk diff --git a/.github/workflows/test-resequence.yml b/.github/workflows/test-resequence.yml index d280c5f16..ae05df8e0 100644 --- a/.github/workflows/test-resequence.yml +++ b/.github/workflows/test-resequence.yml @@ -35,7 +35,7 @@ jobs: with: repository: 0xPolygon/kurtosis-cdk path: kurtosis-cdk - ref: v0.2.22 + ref: v0.2.23 - name: Install Kurtosis CDK tools uses: ./kurtosis-cdk/.github/actions/setup-kurtosis-cdk From 96ee8c7b8a5720e1735d0f821b376d61bfa3584d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Mon, 2 Dec 2024 15:36:54 +0100 Subject: [PATCH 08/10] fix: use kurtosis v0.2.24 --- .github/workflows/test-e2e.yml | 2 +- .github/workflows/test-resequence.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index a44b129a1..7159fb361 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -39,7 +39,7 @@ jobs: with: repository: 0xPolygon/kurtosis-cdk path: kurtosis-cdk - ref: v0.2.23 + ref: v0.2.24 - name: Install Kurtosis CDK tools uses: ./kurtosis-cdk/.github/actions/setup-kurtosis-cdk diff --git a/.github/workflows/test-resequence.yml b/.github/workflows/test-resequence.yml index ae05df8e0..2625017c9 100644 --- a/.github/workflows/test-resequence.yml +++ b/.github/workflows/test-resequence.yml @@ -35,7 +35,7 @@ jobs: with: repository: 0xPolygon/kurtosis-cdk path: kurtosis-cdk - ref: v0.2.23 + ref: v0.2.24 - name: Install Kurtosis CDK tools uses: ./kurtosis-cdk/.github/actions/setup-kurtosis-cdk From 8d651f79a40242ec64da1030f049b43056f51ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Mon, 2 Dec 2024 16:01:18 +0100 Subject: [PATCH 09/10] fix: upgrade the contracts images --- test/combinations/fork11-rollup.yml | 2 +- test/combinations/fork12-cdk-validium.yml | 2 +- test/combinations/fork12-pessimistic.yml | 2 +- test/combinations/fork12-rollup.yml | 2 +- test/combinations/fork9-cdk-validium.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/combinations/fork11-rollup.yml b/test/combinations/fork11-rollup.yml index a0ffba40f..80491430f 100644 --- a/test/combinations/fork11-rollup.yml +++ b/test/combinations/fork11-rollup.yml @@ -1,5 +1,5 @@ args: - zkevm_contracts_image: leovct/zkevm-contracts:v7.0.0-rc.2-fork.11 + zkevm_contracts_image: leovct/zkevm-contracts:v7.0.0-rc.2-fork.11-patch.1 zkevm_prover_image: hermeznetwork/zkevm-prover:v7.0.2-fork.11 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.1.2 zkevm_node_image: hermeznetwork/zkevm-node:v0.7.0-fork11-RC1 diff --git a/test/combinations/fork12-cdk-validium.yml b/test/combinations/fork12-cdk-validium.yml index 0836fb083..f4d914c67 100644 --- a/test/combinations/fork12-cdk-validium.yml +++ b/test/combinations/fork12-cdk-validium.yml @@ -1,5 +1,5 @@ args: - zkevm_contracts_image: leovct/zkevm-contracts:v8.0.0-rc.4-fork.12 + zkevm_contracts_image: leovct/zkevm-contracts:v8.0.0-rc.4-fork.12-patch.1 zkevm_prover_image: hermeznetwork/zkevm-prover:v8.0.0-RC12-fork.12 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.1.2 cdk_node_image: cdk diff --git a/test/combinations/fork12-pessimistic.yml b/test/combinations/fork12-pessimistic.yml index ebac2c514..83c37c790 100644 --- a/test/combinations/fork12-pessimistic.yml +++ b/test/combinations/fork12-pessimistic.yml @@ -5,7 +5,7 @@ args: zkevm_bridge_proxy_image: haproxy:3.0-bookworm zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.6.0-RC1 zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network - zkevm_contracts_image: nulyjkdhthz/zkevm-contracts:v9.0.0-rc.3-pp-fork.12 + zkevm_contracts_image: nulyjkdhthz/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1 additional_services: [] consensus_contract_type: pessimistic sequencer_type: erigon diff --git a/test/combinations/fork12-rollup.yml b/test/combinations/fork12-rollup.yml index ca597faa3..32d3ef8e4 100644 --- a/test/combinations/fork12-rollup.yml +++ b/test/combinations/fork12-rollup.yml @@ -1,5 +1,5 @@ args: - zkevm_contracts_image: leovct/zkevm-contracts:v8.0.0-rc.4-fork.12 + zkevm_contracts_image: leovct/zkevm-contracts:v8.0.0-rc.4-fork.12-patch.1 zkevm_prover_image: hermeznetwork/zkevm-prover:v8.0.0-RC12-fork.12 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.1.2 cdk_node_image: cdk diff --git a/test/combinations/fork9-cdk-validium.yml b/test/combinations/fork9-cdk-validium.yml index 67b23bd09..515819b62 100644 --- a/test/combinations/fork9-cdk-validium.yml +++ b/test/combinations/fork9-cdk-validium.yml @@ -1,5 +1,5 @@ args: - zkevm_contracts_image: leovct/zkevm-contracts:v6.0.0-rc.1-fork.9 + zkevm_contracts_image: leovct/zkevm-contracts:v6.0.0-rc.1-fork.9-patch.1 zkevm_prover_image: hermeznetwork/zkevm-prover:v6.0.6 cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.1.2 zkevm_node_image: hermeznetwork/zkevm-node:v0.7.3-RC1 From e8ef7c65e2826debaa3240b9d4e477e6947780ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Mon, 2 Dec 2024 16:12:49 +0100 Subject: [PATCH 10/10] fix: use the correct contracts Docker image for fork 12 --- test/combinations/fork12-pessimistic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/combinations/fork12-pessimistic.yml b/test/combinations/fork12-pessimistic.yml index 83c37c790..a3734f6ab 100644 --- a/test/combinations/fork12-pessimistic.yml +++ b/test/combinations/fork12-pessimistic.yml @@ -5,7 +5,7 @@ args: zkevm_bridge_proxy_image: haproxy:3.0-bookworm zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.6.0-RC1 zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network - zkevm_contracts_image: nulyjkdhthz/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1 + zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1 additional_services: [] consensus_contract_type: pessimistic sequencer_type: erigon