From 618e3f3910fa428c2e3113035ed7d07311f0dc07 Mon Sep 17 00:00:00 2001 From: Rachit Sonthalia <54906134+rachit77@users.noreply.github.com> Date: Mon, 12 Feb 2024 20:39:21 +0530 Subject: [PATCH] Pullupstream/v0.5.8 (#74) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix migration batch wip field. fix sequence when no wip batch (#3126) * fix Leaves smtproof (#3127) * fix Leaves smtproof * pointer protection * fix unit test * Add l2block log dump when storing error. Refactor ProcessBatchV2 logs (#3129) * add l2block log dump when storing error. refactor ProcessBatchV2 logs * add AddL2Block log * fix index AddL2Block log * use aux variable to avoid reusing poiner --------- Co-authored-by: Toni Ramírez * fix panic etherman (#3133) * Fix GetL2Hash function. Use tx L2 hash returned by the executor when storing L2Block. Logs changes (#3134) * fix l2 hash when to is nill * get l2 hash from executor * fix use tx L2 hash returned by the executor when storing L2Block. Logs changes * fix linter * add L2block tracking number to process tx logs * fix ProcessBatchV2 log format * fix UTs. set useMainExecGenerated to true * set prover image to v4.0.0-RC30 * test setting useMainExecGenerated = false * fix independent_test * fix non-e2e tests --------- Co-authored-by: Toni Ramírez * remove l2 tx hash computation and use data stored in the state returned by the executor (#3139) * etrog: fix permissionless errors (#3140) * if got an error getting lastBlock produce a SIGSEGV * reduce info logs * fix unittest * Fix missing batch bookmark (#3122) * fix missingBookMark * fix missingBookMark * fixes * fix * fix * fix seq-sender config * fixes * doc * fix wipL2Block deltaTimestamp (#3142) * improve open new wipL2Block logs * fix wipL2Block deltaTimestamp * ensure tx order in stream (#3144) * fix wipL2Block stateRoot (#3145) * fix panic NewStackTrie (#3146) * fix sync initalization for etrog (#3147) * fix wipL2block imStateRoot (#3148) * fix tracer to work by block stateroot instead of by tx (#3150) * update prover image (#3151) * if a trusted batch is empty and WIP just create the entry in state.batch (#3152) * fix trace for tx index greater than 0 (#3153) * add cardona.zip (#3154) * Fix default value when creating transaction.used_sha256_hashes field in the pool (#3156) * set DEFAULT 0 when creatingtransaction.used_sha256_hashes field in the pool * update prover image to v4.0.0 * add cardona testnet (#2909) (#3155) * add cardona testnet (#2909) * update config * update cardona genesis --------- Co-authored-by: Thiago Coimbra Lemos * new fields in stream (#3149) * new fields in stream * update test * remove unused constant * add UpgradeEtrogBatchNumber handling to stream * doc * add log to test * add log to test * add protection * add check * fix * fix * set stateManagerPurge to false in Cardona (#3158) * synchronizer: fix case emtpy batch and unittest (#3159) * fix case emtpy batch and unittest * fix error in conversion * fix unittest * update prover image to v4.0.1 (#3160) * update prover image to v4.0.2 (#3162) * Add a note in deployment instruction to restart rpc after forkId 7 (#3163) * note to restart zkevm-rpc * update comment * change position of point 10 * add point 11 * add lines * add breakline * add lines * add line * Sync old network compatibility (#3166) * Sync old network compatibility * logs * synchronizer: unittest and remove pool_reorg (#3111) (#3168) * removed reorgPool call * add test for l1 sequenced batches * removed panic after halt call as PR comments ask for * fix parentHash when storing a new L2 block (#3171) * Fix/rom error (#3177) * fix rom error * linter * fix * Cherrypick/#3179 geth version v1.13.11 (#3180) * new geth version v1.13.11 * Add sanity check: last L2 block timestamp in the sequence is also L1BlockTimestampMargin seconds behind "now" (#3181) * add sanity check L1BlockTimestampMargin vs now * Update prover image to v4.0.4 * synchronizer: update fromTrusted fix cache update (#3169) * fix cache update and sync from Trusted of closed batch * Feature/3173 sync trusted state in networks previous to ETROG (#3175) * Fix/3164 eth syncing dont return expected values (#3165) * fix im state root in stream (#3192) * sync: fix getting URL from contract in compatibility mode, and set sequential by default (#3191) * fix getting URL from contract in compatibility mode * synchronizer configuration by default use `sequential` mode * Fix isSynced function (#3188) * fix isSynced * fix linter * fix logs * halt on sanity check error * fix l2 block gas price to use value returned by the executor (#3186) (#3190) * allow rpc to access the ForkID directly from DB (#3196) * allow rpc to access the ForkID directly from DB * update docs * allow rpc to access the ForkID directly from DB (#3197) * allow rpc to access the ForkID directly from DB * update docs * fix migration down; check for greater forkIDs instead of the next +1 (#3182) * fix state storage config initialization * add tests and fix get forkID by block number * fix test TestGetForkIDByBlockNumber --------- Co-authored-by: agnusmor * Fix/3200 l1inforoot error on reorg (#3201) * L1InfooTree cache is calculated when needed and is discard when a reorg happens * Fix/3203 panic if batch process fail and must be closed (#3206) * synchronizer avoid panic if process trusted batch fails * Remove L1SynchronizationMode parameter from environments config files (it will use default "sequential" value) (#3210) * allow GetL2TxHashByTxHash to return null for txs prior to Etrog (#3209) * Fix L2 block gas limit to 2**50 (1125899906842624) (#3219) * set l2 block gas limit to 2**50 (1125899906842624) * limit L2 block gasLimit in StoreL2Block function * change 2^64-1 for an esmitation of blocks (#3220) * removed restart RPC on deploy instructions (#3221) * Cherry pick/3222 (#3224) * fix stream * fix stream * fix stream * fix stream * linter * add retries in is Synced function when last virtual batch is greater than last SC sequenced batcj (#3225) * Fix/3233 the etrog event UpdateEtrogSequence doesnt store the GER in batch table (#3234) * remove state.batch section from environments config files (#3230) * get GER for l2block on Etrog (#3238) * Cherry-pick #3240, #3137: Sequence batch only when sanity check is done. Do fatal for some finalizer halt events. Several fixes. Optmize purge pool (#3241) * sequence batch only when sanity check is done. Do fatal for some halt events. Several fixes * feat: optimize purge txn pool query (#3137) * feat: optimize purge txn pool query * fix: add new method to state interface * feat: generate new state mocks * fix merge * fix %w --------- Co-authored-by: Idris Hanafi * fix * docs update * fix --------- Co-authored-by: agnusmor <100322135+agnusmor@users.noreply.github.com> Co-authored-by: Alonso Rodriguez Co-authored-by: Toni Ramírez Co-authored-by: Thiago Coimbra Lemos Co-authored-by: Joan Esteban <129153821+joanestebanr@users.noreply.github.com> Co-authored-by: Toni Ramírez <58293609+ToniRamirezM@users.noreply.github.com> Co-authored-by: agnusmor Co-authored-by: Idris Hanafi --- aggregator/mocks/mock_etherman.go | 2 +- db/migrations/state/0016.sql | 7 + db/migrations/state/0016_test.go | 64 + docs/diff/diff.html | 42217 +++++++++------- docs/diff/diff.md | 2 +- etherman/simulated.go | 2 +- go.mod | 2 +- go.sum | 12 +- pool/interfaces.go | 1 + pool/pgpoolstorage/pgpoolstorage.go | 20 + sequencer/batch.go | 68 +- sequencer/errors.go | 2 + sequencer/finalizer.go | 20 +- sequencer/forcedbatch.go | 18 +- sequencer/interfaces.go | 27 +- sequencer/l2block.go | 44 +- sequencer/mock_etherman.go | 59 - sequencer/mock_pool.go | 30 + sequencer/mock_state.go | 607 +- sequencer/sequencer.go | 10 +- sequencesender/interfaces.go | 1 + sequencesender/mock_state.go | 28 + sequencesender/sequencesender.go | 15 +- state/datastream.go | 2 - state/interfaces.go | 4 + state/mocks/mock_storage.go | 226 + state/pgstatestorage/batch.go | 49 +- state/pgstatestorage/datastream.go | 10 +- state/pgstatestorage/transaction.go | 61 + .../processor_l1_update_etrog_sequence.go | 4 +- test/Makefile | 9 +- 31 files changed, 25618 insertions(+), 18005 deletions(-) create mode 100644 db/migrations/state/0016.sql create mode 100644 db/migrations/state/0016_test.go diff --git a/aggregator/mocks/mock_etherman.go b/aggregator/mocks/mock_etherman.go index bde6db5c0d..1e2079dd77 100644 --- a/aggregator/mocks/mock_etherman.go +++ b/aggregator/mocks/mock_etherman.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. +// Code generated by mockery v2.39.0. DO NOT EDIT. package mocks diff --git a/db/migrations/state/0016.sql b/db/migrations/state/0016.sql new file mode 100644 index 0000000000..b51ef47a05 --- /dev/null +++ b/db/migrations/state/0016.sql @@ -0,0 +1,7 @@ +-- +migrate Up +ALTER TABLE state.batch + ADD COLUMN IF NOT EXISTS checked BOOLEAN NOT NULL DEFAULT TRUE; + +-- +migrate Down +ALTER TABLE state.batch + DROP COLUMN IF EXISTS checked; \ No newline at end of file diff --git a/db/migrations/state/0016_test.go b/db/migrations/state/0016_test.go new file mode 100644 index 0000000000..cab53501b9 --- /dev/null +++ b/db/migrations/state/0016_test.go @@ -0,0 +1,64 @@ +package migrations_test + +import ( + "database/sql" + "testing" + + "github.com/stretchr/testify/assert" +) + +type migrationTest0016 struct{} + +func (m migrationTest0016) InsertData(db *sql.DB) error { + const insertBatch0 = ` + INSERT INTO state.batch (batch_num, global_exit_root, local_exit_root, acc_input_hash, state_root, timestamp, coinbase, raw_txs_data, forced_batch_num, wip) + VALUES (0,'0x0000', '0x0000', '0x0000', '0x0000', now(), '0x0000', null, null, true)` + + // insert batch + _, err := db.Exec(insertBatch0) + if err != nil { + return err + } + + return nil +} + +func (m migrationTest0016) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { + var result int + + // Check column checked exists in state.batch table + const getCheckedColumn = `SELECT count(*) FROM information_schema.columns WHERE table_name='batch' and column_name='checked'` + row := db.QueryRow(getCheckedColumn) + assert.NoError(t, row.Scan(&result)) + assert.Equal(t, 1, result) + + const insertBatch0 = ` + INSERT INTO state.batch (batch_num, global_exit_root, local_exit_root, acc_input_hash, state_root, timestamp, coinbase, raw_txs_data, forced_batch_num, wip, checked) + VALUES (1,'0x0001', '0x0001', '0x0001', '0x0001', now(), '0x0001', null, null, true, false)` + + // insert batch 1 + _, err := db.Exec(insertBatch0) + assert.NoError(t, err) + + const insertBatch1 = ` + INSERT INTO state.batch (batch_num, global_exit_root, local_exit_root, acc_input_hash, state_root, timestamp, coinbase, raw_txs_data, forced_batch_num, wip, checked) + VALUES (2,'0x0002', '0x0002', '0x0002', '0x0002', now(), '0x0002', null, null, false, true)` + + // insert batch 2 + _, err = db.Exec(insertBatch1) + assert.NoError(t, err) +} + +func (m migrationTest0016) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { + var result int + + // Check column wip doesn't exists in state.batch table + const getCheckedColumn = `SELECT count(*) FROM information_schema.columns WHERE table_name='batch' and column_name='checked'` + row := db.QueryRow(getCheckedColumn) + assert.NoError(t, row.Scan(&result)) + assert.Equal(t, 0, result) +} + +func TestMigration0016(t *testing.T) { + runMigrationTest(t, 16, migrationTest0016{}) +} diff --git a/docs/diff/diff.html b/docs/diff/diff.html index 5b635569c2..3931be2be8 100644 --- a/docs/diff/diff.html +++ b/docs/diff/diff.html @@ -2,7 +2,7 @@ - zkEVM node vs CDK validium node</br><h2>zkevm-node version: v0.5.6<h2/> + zkEVM node vs CDK validium node</br><h2>zkevm-node version: v0.5.8<h2/>